﻿Option Strict On
Option Explicit On
Option Infer On

Imports System
Imports System.Linq
Imports System.Collections.Generic
Imports GenDotNet.Task.Common

Public Class RegionInfo
   Inherits BaseInfo

   Private mRegionDelegate As EmptyDelegate

   Public Sub New(ByVal del As EmptyDelegate)
      Me.New(Nothing, del)
   End Sub

   Public Sub New(ByVal name As String, ByVal del As EmptyDelegate)
      MyBase.New(name, Scope.Unknown)
      If String.IsNullOrEmpty(Me.Name) Then
         Me.Name = del.Method.Name.SpaceAtCaps
      End If
      Me.mRegionDelegate = del
   End Sub

   Public ReadOnly Property RegionDelegate() As EmptyDelegate
      Get
         Return mRegionDelegate
      End Get
   End Property

   Public Shadows Property Scope() As Scope
      Get
         Throw New InvalidOperationException("You can't access scope for a region")
      End Get
      Set(ByVal value As Scope)
         Throw New InvalidOperationException("You can't access scope for a region")
      End Set
   End Property

   Public Shadows ReadOnly Property Attributes() As AttributeInfoCollection
      Get
         Throw New InvalidOperationException("You can't access attributes for a region")
      End Get
   End Property

End Class

Namespace VB
   Public Module RegionInfoExtensions
      <Runtime.CompilerServices.Extension()> _
      Public Function Output(ByVal info As RegionInfo) As String
         Return _
   <code>
#Region "<%= info.Name %>"
<%= info.RegionDelegate.Invoke() %>
#End Region
</code>.Value
      End Function
   End Module
End Namespace

Namespace CSharp
   Public Module RegionInfoExtensions
      <Runtime.CompilerServices.Extension()> _
      Public Function Output(ByVal info As RegionInfo) As String
         Return _
   <code>
#region <%= info.Name %><%= Strings.nl %>
      <%= info.RegionDelegate.Invoke() %>
#endregion
</code>.Value
      End Function
   End Module
End Namespace
